package com.lifeng.patterns.factory.simpleFactory;

/**
 * Created by lifeng on 2019/9/18.
 * 简单工厂:后厨就相当于一个工厂生产面
 */
public class SimpleNoodlesFactory {
    public static final String DAOXIAO = "daoxiao";
    public static final String LANZHOU = "lanzhou";
    public static final String PAO = "pao";
    /**生产面条*/
    public static INoodles createNoodles(String type) throws Exception {
        INoodles noodles = null;
        try{
            switch (type){
                case DAOXIAO:noodles = new DaoXiaoNoodles();break;
                case LANZHOU:noodles = new LanZhouNoodles();break;
                case PAO:noodles = new PaoNoodles();break;
                default:
                    System.out.println("不支持");break;
            }
        }catch (Exception e){
            System.out.println("创建异常");
            throw e;
        }
        return noodles;
    }
}
